package com.yimi.policyservice.repository;

import com.yimi.policyservice.entity.base.system.SysUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface UserRepository extends JpaRepository<SysUser,String> {
    SysUser findFirstByLoginName(String loginName);

    SysUser findFirstBySystemUserId(String systemUserId);

    SysUser findFirstByLoginNameAndPassword(String loginame, String md5);

    SysUser findFirstByTelephone(String phone);

    /**
     * 删除用户
     * @param ids
     */
    @Modifying
    @Transactional
    @Query(value = "delete from t_sys_user where id in ?1",nativeQuery = true)
    void deleteByIdIn(List<String> ids);


    @Modifying
    @Transactional
    @Query(value = "update  t_sys_user  u set u.telephone = ?1 and u.id=?2",nativeQuery = true)
    void updatePhone(String phone, String id);
}
